<?php
namespace app\index\controller;

use app\index\model\Evalutedesc;
use app\index\model\Evalute;
use think\Cache;
use think\Exception;
use think\File;

class Evalutes extends Comm
{
    /**
     * 论坛评论
     */
    public function index()
    {
        $re=Evalute::evalutes();
        $audit=Cache::remember('audit',function(){
            return 0;
        });
        return view('evalute',['evalute'=>$re,'i'=>1,'audit'=>$audit]);
    }
    public function setAudit()
    {
        if($_POST['checked']=='true'){
            Cache::set('audit',1);
        }else{
            Cache::set('audit',0);
        }
    }
    //评论回复详情
    public function desc()
    {
        $id=$_GET['id'];
        $res=Evalute::getEvaluteById($id);
        $re=Evalutedesc::getEvalutedescById($id);
        return view('evalutedesc',['evalutedesc'=>$re,'evalute'=>$res]);
    }
    //评论删除
    public function del()
    {
        $id=$_POST['id'];
        $re=Evalute::delEvaluteById($id);
    }
    //修改评论是否置顶
    public function updstick()
    {
        $evalute=Evalute::get($_POST['id']);
        if($_POST['checked']=='true'){
            $evalute->stick=1;
            $evalute->save();
        }else{
            $evalute->stick=0;
            $evalute->save();
        }
    }
    //修改评论是否审核
    public function updaudit()
    {
        $evalute=Evalute::get($_POST['id']);
        if($_POST['checked']=='true'){
            $evalute->audit=1;
            $evalute->save();
        }else{
            $evalute->audit=0;
            $evalute->save();
        }
    }
}
 ?>
